package com.qf.tms.controller;

import com.qf.tms.entity.StudentVO;
import com.qf.tms.entity.Subjects;
import com.qf.tms.service.StudentServiceV2;
import com.qf.tms.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "学生模块业务层拆分")
public class StudentControllerV2 {
    @Autowired
    private StudentServiceV2 studentServiceV2;


    @GetMapping("/stu/select/stu&classroomV2")
    @ApiOperation(value = "查询所有学生信息及对应的班级信息")
    public R selectStuAndClassroomAllV2() {

        List<StudentVO> stuVOList = studentServiceV2.selectStuAndCmAllV2();
        if (stuVOList != null) {
            return R.success(stuVOList);
        }else {
            return R.fail();
        }
    }


    /**
     * 查询一个学生信息以及所学习的所有学科信息
     */
    @GetMapping("/stu/select/subjectV2/{stuId}")
    @ApiOperation(value = "查询一个学生信息以及所学习的所有学科信息")
    public R findStuSub(@PathVariable int stuId) {
        StudentVO studentVO = studentServiceV2.findStuSub(stuId);
        if (studentVO != null) {
            System.out.println(studentVO);
            return R.success(studentVO);
        }else  {
            return R.fail();
        }
    }
}
